/*
 * parse_superblock_file - read the superblock file, and init the structure sb
 * @param   superblock_filepath  the path of the superblock file
 * @param   sb                   pointer the structure of the superblock
 * @return  Return the flag whether the function is executed successfully,
 *          0 is success, 1 is failed.
 */
	
int
parse_superblock_file(char *superblock_filepath, lhdfs_super_block *sb)
{
	DIR *dir;
    struct dirent *ptr = NULL;
	struct super_block buf;
	int fd;
    int count;                          //the word of the file
		
	dir = opendir(superblock_filepath);
    if(dir == NULL)
	{
      perror("opendir error!");
      return EDIR;
	}
				
    while( (ptr = readdir(dir)) != NULL)
	{
		if ( strcmp(ptr->d_name, "superblock.conf") == 0)
		{
	          fd = open("superblock.conf", O_RDONLY);
              if(fd == -1)
			  {
	               perror("open error!");
	               exit(-1);
			  }
			  count = read(fd, &sb_buf, sizeof(struct lhdfs_super_block));
			  if(count != sizeof(struct lhdfs_super_block))
			  {
					perror("read error!");
					return EFILE;
			  }
		}
	}
					  
	return 0;
}
